<?php
/**************************************************************************
 *
 *   Copyright 2010 American Public Media Group
 *
 *   This file is part of AIR2.
 *
 *   AIR2 is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   AIR2 is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with AIR2.  If not, see <http://www.gnu.org/licenses/>.
 *
 *************************************************************************/

/*
|--------------------------------------------------------------------------
| AIR2 Activity search page
|--------------------------------------------------------------------------
*/
$search_url = $c->uri_for('search.json', array('gzip' => $use_gzip, 'i'=>'activities'));
$act_url    = $c->uri_for('source');
?>
<script type="text/javascript">
    Ext.onReady(function() {

        AIR2.Search.URL     = '<?php echo $c->uri_for("search") ?>';
        AIR2.Search.QUERY   = '<?php echo htmlspecialchars($q, ENT_QUOTES) ?>';
        AIR2.Search.PARAMS  = <?php echo Encoding::json_encode_utf8($params) ?>;
        AIR2.Search.IDX     = 'activities';

        var resultTpl = new Ext.XTemplate(
           '<tpl for=".">',
            '<div class="air2-search-result">',
             '<div class="link">',
              '<a class="title" href="<?php echo $act_url ?>/{src_uuid}">{title}</a>',
             '</div>',
             '<div class="summary">{summary}</div>',
            '</div>',
           '</tpl>'
        );

        var facetDefs = {
            org_uuid : {
                label : 'Organization',
                itemLabels : <?php echo Encoding::json_encode_utf8($org_names) ?>
            },
            actm_id : {
                label : 'Type',
                itemLabels : <?php echo Encoding::json_encode_utf8($act_names) ?>
            }
        };

        var app = new AIR2.UI.App({
            items: AIR2.SearchPanel({
                title       : 'Activities',
                searchUrl   : '<?php echo $search_url ?>',
                resultTpl   : resultTpl,
                facetDefs   : facetDefs
            })
        });

    });
</script>
